package comparatorTest;

import java.util.Comparator;

public class ByHeightComparator implements Comparator {

 

    public int compare(Object firstDog, Object secondDog) {

       int firstHeight = ((Dog) firstDog).getHeight();

       int secondHeight = ((Dog) secondDog).getHeight();

       return signum(firstHeight - secondHeight);

    }

 

    public static final int signum(int diff) {

       if (diff > 0)

           return 1;

       if (diff < 0)

           return -1;

       else

           return 0;

    }

 

}
